package com.owen.java.demo.guava;

import com.google.common.util.concurrent.RateLimiter;
import net.sourceforge.groboutils.junit.v1.TestRunnable;

/**
 * 文档请参考
 * http://ifeve.com/guava-ratelimiter/
 *
 * 官方教程请参考
 * http://ifeve.com/google-guava/#more-8776
 */
public class MyThread extends TestRunnable {

    private RateLimiter rateLimiter = RateLimiter.create(2.0);

    @Override
    public void runTest() throws Throwable {
        for (int i=0;i<Integer.MAX_VALUE;i++) {
//            rateLimiter.acquire(); // 也许需要等待
            System.out.println("======="+i+"=======");
        }
    }
}
